﻿@page "/list_detail1"

<div class="p-3">
    <div class="form-inline">
        <div class="form-group mr-3">
            <label class="mr-3">炉号</label>
            <BootstrapInput TValue="string" />
        </div>
        <div class="form-group">
            <label class="mr-3">批号</label>
            <BootstrapInput TValue="string" />
        </div>
    </div>
    <div class="mb-3">
        <Button Text="搜索" />
        <Button Text="功能按钮1" />
    </div>
    <div class="mb-3">
        <Card>
            <CardHeader>库存数据</CardHeader>
            <CardBody>
                <Table TItem="TsbCode" ShowSkeleton="true"
                       IsPagination="true" PageItemsSource="@PageItemsSource"
                       IsStriped="true" IsBordered="true"
                       IsMultipleSelect="true" OnQueryAsync="@OnQueryAsync">
                    <TableColumns>
                        <TableColumn @bind-Field="@context.CodeClass" Sortable="true" Text="编码" />
                        <TableColumn @bind-Field="@context.CodeName" Sortable="true" Text="名称" />
                        <TableColumn @bind-Field="@context.CodeSource" Sortable="true" Text="来源" />
                        <TableColumn @bind-Field="@context.CodeDesc1Name" Sortable="true" Text="描述1" Filterable="true" />
                        <TableColumn @bind-Field="@context.CodeDesc1Name" Sortable="true" Text="描述2" />
                        <TableColumn @bind-Field="@context.CodeDesc1Name" Sortable="true" Text="描述3" />
                        <TableColumn @bind-Field="@context.CodeDesc1Name" Sortable="true" Text="描述4" />
                    </TableColumns>
                </Table>
            </CardBody>
        </Card>
    </div>
    <div>
        <Card>
            <CardHeader>
                成分信息 性能信息 库存信息
            </CardHeader>
            <CardBody>
                <div class="row">
                    <div class="col-4">
                        <label class="control-label">入库时间</label>
                        <BootstrapInput TValue="string" />
                    </div>
                    <div class="col-4">
                        <label class="col-form-label">入库人</label>
                        <BootstrapInput TValue="string" />
                    </div>
                    <div class="col-4">
                        <label class="col-form-label">库存名称</label>
                        <BootstrapInput TValue="string" />
                    </div>
                    <div class="col-4">
                        <label class="col-form-label">入库班次</label>
                        <BootstrapInput TValue="string" />
                    </div>
                    <div class="col-4">
                        <label class="col-form-label">入库班组</label>
                        <BootstrapInput TValue="string" />
                    </div>
                    <div class="col-4">
                        <label class="col-form-label">储位名称</label>
                        <BootstrapInput TValue="string" />
                    </div>
                </div>
            </CardBody>
        </Card>
    </div>
</div>

@code {
    private IEnumerable<int> PageItemsSource => new int[] { 4, 8, 12, 20 };

    private List<TsbCode> TsbCodes { get; set; } = InitTsbCodes();

    private static List<TsbCode> InitTsbCodes() => Enumerable.Range(1, 80).Select(i => new TsbCode()
    {
        CodeClass = "CodeClass" + i,
        CodeName = "CodeName" + i,
        CodeSource = "CodeSource" + i,
        CodeDesc1Name = "CodeDesc1Name" + i,
        CodeDesc2Name = "CodeDesc2Name" + i,
        CodeDesc3Name = "CodeDesc3Name" + i,
        CodeDesc4Name = "CodeDesc4Name" + i,
    }).ToList();

    private Task<QueryData<TsbCode>> OnQueryAsync(QueryPageOptions options) => BindItemQueryAsync(TsbCodes, options);

    private Task<QueryData<TsbCode>> BindItemQueryAsync(IEnumerable<TsbCode> items, QueryPageOptions options)
    {
        var total = items.Count();
        items = items.Skip((options.PageIndex - 1) * options.PageItems).Take(options.PageItems).ToList();

        return Task.FromResult(new QueryData<TsbCode>()
        {
            Items = items,
            TotalCount = total
        });
    }
}